package com.leetcode.No1893;

/**
 * @program: leetcode
 * @description: 检查是否区域内所有整数都被覆盖
 * @author: wangzhihua
 * @date: 2021-07-24
 */
public class Solution02 {

	public boolean isCovered(int[][] ranges, int left, int right) {
		int[] coveredNum = new int[52];

		for (int[] range : ranges) {
			++coveredNum[range[0]];
			--coveredNum[range[1] + 1];
		}
		int count = 0;
		for (int i = 1; i <= right; ++i) {
			count += coveredNum[i];
			if (i >= left && count <= 0) {
				return false;
			}
		}
		return true;
	}

}
